//
//    Display the origin axis of a space
//


-- VS


layout(location=0) in vec4 inPosition;

out block {
  vec4 position;
} Out;

void main()
{
  vec4 base= vec4(0.0f,0.0f,0.0f,1.0f);
  Out.position = inPosition;
}


--

//------------------------------------------------------------------------------

-- GS


layout(points) in;
layout(line_strip, max_vertices=6) out;

in block {
  vec4 position;
} In[];

out block {
  vec3 color;
} Out;

uniform mat4 uMVP;


void emitAxis( vec3 axis )
{
  Out.color = axis;
  gl_Position = uMVP * In[0].position; 
  EmitVertex();
  
  Out.color = axis;
  gl_Position = uMVP * vec4( In[0].position.xyz + axis, 1.0f);
  EmitVertex();
}

void main()
{
  emitAxis( vec3( 1.0f, 0.0f, 0.0f) );
  EndPrimitive();
  emitAxis( vec3( 0.0f, 1.0f, 0.0f) );
  EndPrimitive();
  emitAxis( vec3( 0.0f, 0.0f, 1.0f) );  
  EndPrimitive();
}


--

//------------------------------------------------------------------------------

-- FS


in block {
  vec3 color;
} In;

out vec3 fragColor;


void main()
{
  fragColor = In.color;
}

